package com.fh.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("redis")
public class TestRedisTemplate {
    @Autowired
    private RedisTemplate redisTemplate;//redis的操作类

    @RequestMapping("set")
    public String test(String key,String value){
        redisTemplate.opsForValue().set(key,value);
        return "success";
    }

    @RequestMapping("get")
    public String test2(String key){
        return (String) redisTemplate.opsForValue().get(key);
    }

}
